/*
 * Created by Administrator on 2017/3/31.
 */
var Password = require('../../../../src/libs/password');
var Layer = require('../../../../src/libs/layer');
var Form = require('../../../../src/libs/form');
var FormItem = require('../../../../src/libs/form-item');
var BankCard = React.createClass({
    getInitialState: function() {
        return{
            data:this.props.data

        }
    },
    delBankCardHandler: function (item) {
        var _this = this;
        PageDM.cardList.delclick(item.UserBankAccountId)
        _this.refs.changeForm.reset();
    },
    componentDidMount:function(){
        var _this = this;
        UEventHub.on('LayerOpen',function (v) {
                _this.refs[v].layerOpen();


        });
        UEventHub.on('LayerClose',function (v) {
                _this.refs[v].layerClose();
        });
    },
    closeReset:function () {
        PageDM.dclayer.closeBack&&PageDM.dclayer.closeBack();
    },
    render: function () {
        var _this = this;
        return(<div>
                {this.state.data.map(function (item,index) {
                    return (
                        <div className="item">
                            <span className={"ucs-bank-logo "+item.BankLogo}></span>
                            <span className="type">储蓄卡</span>
                            <div></div>
                            <div className="num">{item.AccountNo}</div>
                            <div className="name">{item.AccountName}</div>
                            <p className="del"><a href="javascript:;" className="iconfont icon-del" onClick={_this.delBankCardHandler.bind(_this,item)}></a></p>
                        </div>
                    )
                })
                }
                <Layer ref={PageDM.dclayer.dmbind} width="720px" getContainer="list"  className="layer-addbank" closeBack={_this.closeReset}>

                    <div className="alert-title" style={{paddingTop:"0"}}><b></b>请输入支付密码<b></b></div>
                    <div className="alert-content" >
                        <div className="tips fc-main"><i className="iconfont icon-tips"></i>删除后如您再次购买项目，需要重新绑定银行卡。</div>
                        <div className="form">
                            <Form ref="changeForm">
                                <FormItem label="<b>*</b>支付密码：" dmbind={PageDM.dcPassword.dmbind}>
                                    <Password placeholder={PageDM.dcPassword.placeholder}  dmbind={PageDM.dcPassword.dmbind}/>
                                </FormItem>
                            </Form>
                        </div>
                        <div className="alert-button">
                            <input type="button" className="btn btn-confirm confirm-addbank" value="确认"  onClick={PageDM.dclayer.confirmBack}/>
                            <input type="button" className="btn btn-cancel " onClick={PageDM.dclayer.cancelBack} value="取消"/>
                        </div>
                    </div>
                </Layer>
            </div>
            )

    }
})

module.exports = BankCard;